package com.feiyuan.core.controller.admin;

import com.feiyuan.common.result.R;
import com.feiyuan.core.annotation.FeiyuanRequiresPermissions;
import com.feiyuan.core.pojo.entity.SysQuartzJobLog;
import com.feiyuan.core.service.SysQuartzJobLogService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api("定时任务日志")
@RestController
@RequestMapping("/admin/core/quartzLog")
public class AdminQuartzJobLogController {

    @Autowired
    private SysQuartzJobLogService quartzJobLogService;

    /**
     * 查询日志详情
     * @return
     */
    @ApiOperation("查询定时任务日志详情")
    @GetMapping("/list")
    @FeiyuanRequiresPermissions("admin:quartzLog:list")
    public R list(@RequestParam Integer pageNo, @RequestParam Integer pageSize) {
        return R.ok().data("pages", quartzJobLogService.page(new Page<SysQuartzJobLog>(pageNo, pageSize),
                new QueryWrapper<SysQuartzJobLog>().orderByDesc("create_time")));
    }
}
